﻿@inherits MasaComponentBase

<SSheetDialog EnableDomReload Value="Value" ValueChanged="SheetDialogValueChangedAsync" Title="@T("Add config object")" Icon="mdi-circle" IconColor="success">
    <MForm Class="full-height" Context="formContext" EnableValidation Model="_addConfigObjectModal.Data">
        <div class="d-flex flex-column" style="width:100%; height:100%; padding: 48px 228px; overflow: hidden;">
            <div class="full-height" style="overflow: auto;">
                <div class="emphasis--text h6 d-flex align-center">
                    @AppDetail.Name
                    <span class="ml-3 regular3--text btn">|</span>
                    <sapn class="ml-2 regular3--text btn">@AppDetail.Identity</sapn>
                </div>
                <STextField Class="mt-12" Dense Label="@T("Name")" Outlined Prefix="@(ConfigObjectType==ConfigObjectType.Public ? _namePrefix : "")" @bind-Value="_addConfigObjectModal.Data.Name"></STextField>
                <SSelect @bind-Value="_addConfigObjectModal.Data.FormatLabelCode"
                         Class="pt-6"
                         Label="@T("Format")"
                         MenuProps="props => props.OffsetY = true"
                         Outlined
                         Dense
                         Items="_configObjectFormats"
                         ItemText="l=>l.Name"
                         ItemValue="l=>l.Code">
                </SSelect>
                <p class="emphasis--text pt-6" style="font-size:14px; font-weight:700;">@T("Enable encryption")</p>
                <MSwitch Class="ml-3 mt-0 enable-encryption" Style="display: inline-block;" @bind-Value="_addConfigObjectModal.Data.Encryption"
                         TValue="bool"
                         Label="@(_addConfigObjectModal.Data.Encryption ? T("ON") : T("OFF"))"
                         Inset>
                </MSwitch>
                <p class="emphasis--text pt-6" style="font-size:14px; font-weight:700;">@T("Please select cluster")</p>
                <MChipGroup Multiple Column Values="_selectEnvClusterIds" ValuesChanged="EnvClusterValueChanged">
                    @foreach (var item in AppDetail.EnvironmentClusters)
                    {
                        <MChip Value="item.Id" Large Class="envClusterChip mr-6 mb-6 m-chip--envcluster" Filter Outlined Style=@($"border-color:{item.EnvironmentColor};color:{item.EnvironmentColor}")>
                            <div>@item.EnvironmentName</div>
                            <span class="split--text">&nbsp; | &nbsp;</span>
                            <div class="emphasis2--text">@item.ClusterName</div>
                        </MChip>
                    }
                </MChipGroup>
            </div>
            <div class="d-flex justify-end align-end" style="width:100%;">
                <SButton Small OnClick="()=>AddConfigObject(formContext)">@T("Submit")</SButton>
            </div>
        </div>
    </MForm>
</SSheetDialog>
